<template>
	<view class="content">
		<uni-list v-if="type==1">
			<uni-list-item title="车辆吨位(吨)" :rightText="formData.vehicleTonnage" />
			<uni-list-item title="车牌号" :rightText="formData.licensePlate" />
			<uni-list-item title="使用单位" :rightText="formData.useUnit" />
			<uni-list-item title="使用地点" :rightText="formData.useAddress" />
			<uni-list-item title="作业内容" :rightText="formData.workContent" />
			<uni-list-item title="指挥人员" :rightText="formData.commandName" />
			<uni-list-item title="操作人员" :rightText="formData.operatives" />
			<uni-list-item title="现场技术员" :rightText="formData.technicianName" />
			<uni-list-item title="现场安全员" :rightText="formData.safetyOfficerName" />
			<uni-list-item title="网格员" :rightText="formData.gridLengthName" />
			<uni-list-item title="现场专监" :rightText="formData.siteSupervisionName" />
			<uni-list-item title="安全专监" :rightText="formData.safetySupervisionName" />
			<uni-section class="mb-10" title="检查要点" type="line"></uni-section>
			<uni-list-item v-for="(item,index) in JSON.parse(formData.inspectionPoints)" :key="index" :title="item.text"
				:rightText="item.value==1?'通过':'不通过'" />
			<uni-section class="mb-10" title=" " type="line"></uni-section>
			<uni-list-item title="施工部位" :rightText="formData.constructionSite" />
			<uni-list-item title="作业班组" :rightText="formData.workTeam" />
			<uni-list-item title="申请事由" :rightText="formData.reasonForApplication" />
			<uni-list-item title="开始时间" :rightText="formData.startTime" />
			<uni-list-item title="结束时间" :rightText="formData.endTime" />
			<uni-list-item title="起重设备" :rightText="formData.liftingEquipment" />
			<uni-list-item title="吊装级别" :rightText="getleave(formData.level)" />
			<uni-list-item title="作业人员" :rightText="formData.operatives" />
			<uni-list-item title="吊装指挥" :rightText="formData.commandName" />
			<uni-list-item title="现场监护人" :rightText="formData.guardianName" />
			<uni-list-item title="班组负责人" :rightText="formData.applicationManagerName" />
			<uni-section class="mb-10" title="安全措施" type="line"></uni-section>
			<uni-list-item v-for="(item,index) in JSON.parse(formData.remark)" :key="index" :title="item.text"
				:rightText="item.value==1?'是':'否'" />
		</uni-list>
		<uni-list v-if="type==2">
			<uni-list-item title="施工部位" :rightText="formData.constructionSite" />
			<uni-list-item title="作业班组" :rightText="formData.workTeam" />
			<uni-list-item title="申请事由" :rightText="formData.reasonForApplication" />
			<uni-list-item title="开始时间" :rightText="formData.startTime" />
			<uni-list-item title="结束时间" :rightText="formData.endTime" />
			<uni-list-item title="动火类型" :rightText="gethotWorkType(formData.hotWorkType)" />
			<uni-list-item title="动火等级" :rightText="getleave(formData.level)" />
			<uni-list-item title="作业人员" :rightText="formData.operatives" />
			<uni-list-item title="现场监护人" :rightText="formData.guardianName" />
			<uni-list-item title="班组负责人" :rightText="formData.applicationManagerName" />

			<uni-section class="mb-10" title="安全措施" type="line"></uni-section>
			<uni-list-item v-for="(item,index) in JSON.parse(formData.remark)" :key="index" :title="item.text"
				:rightText="item.value==1?'是':'否'" />
		</uni-list>
		<uni-list v-if="type==3">

			<uni-list-item title="申请班组" :rightText="formData.workTeam" />
			<uni-list-item title="操作人员" :rightText="formData.operatives" />
			<uni-list-item title="设备编号" :rightText="formData.equipmentCode" />
			<uni-list-item title="作业工点" :rightText="formData.workAddress" />
			<uni-list-item title="天气" :rightText="formData.weather" />
			<uni-list-item title="行走路线起止" :rightText="formData.walkingRoute" />
			<uni-list-item title="行走路线长度" :rightText="formData.walkingRouteLength" />
			<uni-list-item title="开始时间" :rightText="formData.startTime" />
			<uni-list-item title="结束时间" :rightText="formData.endTime" />
			<uni-list-item title="是否有架空线或浅埋管线" :rightText="formData.isOverhead" />
			<uni-list-item title="班组长" :rightText="formData.teamLeaderName" />
			<uni-list-item title="二级网格员" :rightText="formData.gridLengthName" />
			<uni-list-item title="三级网格员" :rightText="formData.gridOperatorName" />
			<uni-list-item title="安全员" :rightText="formData.safetyOfficerName" />
			<uni-list-item title="监理" :rightText="formData.supervisorName" />

			<uni-section class="mb-10" title="安全措施" type="line"></uni-section>
			<uni-list-item v-for="(item,index) in JSON.parse(formData.remark)" :key="index" :title="item.text"
				:rightText="item.value==1?'是':'否'" />
		</uni-list>
		<view class="but">
			<view class="item" @click="handlePass()">
				通过
			</view>
			<view class="item itemNo" @click="handleNoPass()">
				不通过
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getHomework,
		updateHomework
	} from "@/api/homework";
	export default {
		data() {
			return {
				formData: {},
				type: 0,
				formId: 0,
				formStatus: 0,

			}
		},
		onLoad: function(option) {
			this.formId = option.id
			this.formStatus = option.status
			this.getDetail(option.id)
		},
		methods: {
			getDetail(id) {
				getHomework(id).then((res) => {

					this.formData = res.data

					this.type = res.data.type
				})
			},
			handlePass() {
				let obj = {
					id: this.formId,
					status: this.formStatus
				}
				if (this.formStatus == 1) {
					obj.technicalDepartment = '同意'
					obj.technicalDepartmentId = this.$store.getters.id
				} else if (this.formStatus == 2) {
					obj.securitySector = '同意'
					obj.securitySectorId = this.$store.getters.id
				} else if (this.formStatus == 3) {
					obj.projectLeader = '同意'
					obj.projectLeaderId = this.$store.getters.id
				} else if (this.formStatus == 4) {
					obj.safetySupervisionApprovalId = this.$store.getters.id
				} else if (this.formStatus == 5) {
					obj.siteSupervisionApprovalId = this.$store.getters.id
				}
				updateHomework(obj).then((response) => {
					this.$modal.msgSuccess("成功");
					this.$tab.reLaunch('/pages/index')
				});
			},
			handleNoPass() {
				let obj = {
					id: this.formId,
					status: 6
				}
				if (this.formStatus == 1) {
					obj.technicalDepartment = '不同意'
					obj.technicalDepartmentId = this.$store.getters.id
				} else if (this.formStatus == 2) {
					obj.securitySector = '不同意'
					obj.securitySectorId = this.$store.getters.id
				} else if (this.formStatus == 3) {
					obj.projectLeader = '不同意'
					obj.projectLeaderId = this.$store.getters.id
				} else if (this.formStatus == 4) {
					obj.safetySupervisionApprovalId = this.$store.getters.id
				} else if (this.formStatus == 5) {
					obj.siteSupervisionApprovalId = this.$store.getters.id
				}
				updateHomework(obj).then((response) => {
					this.$modal.msgSuccess("成功");
					this.$tab.reLaunch('/pages/index')
				});
			},
			getleave(val) {
				return val == 1 ?
					"一级" :
					val == 2 ?
					"二级" :
					val == 3 ?
					"三级" :
					"";
			},
			gethotWorkType(val) {
				return val == 1 ?
					"电焊" :
					val == 2 ?
					"气焊" :
					val == 3 ?
					"气割" :
					val == 4 ?
					"热熔" :
					val == 5 ?
					"其他" :
					"";
			}
		},
	}
</script>

<style lang="scss" scoped>
	.but {
		display: flex;
		justify-content: space-evenly;
		margin-top: 15px;
		padding-bottom: 55px;

		.item {
			width: 150px;
			height: 30px;
			background-color: #00aaff;
			color: #fff;
			text-align: center;
			line-height: 30px;
			border-radius: 10px;
		}

		.itemNo {
			background-color: #acacac;
		}
	}
</style>